package com.itany.corejava.code07_面向对象.继承;

/**
 * @author 石小俊
 * @date 2023年04月19日 11:23
 */
public class Person {

    private String name;
    private int age;
    private String gender;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public void show() {
        System.out.println("姓名:" + name + ",年龄:" + age + ",性别:" + gender);
    }
}

class Man extends Person {
    private double salary;

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public void work() {
        System.out.println("我是一个男人,我需要赚钱养家,我每个月能赚" + salary + "元");
    }
}

class WoMan extends Person {
    private int appearance; // 颜值0-100

    public int getAppearance() {
        return appearance;
    }

    public void setAppearance(int appearance) {
        this.appearance = appearance;
    }

    public void shopping() {
        System.out.println("我是一个女人,我的颜值可以达到" + appearance + "分,我只需要负责貌美如花,没事逛逛街,购购物");
    }
}

// 猫继承人不合理,实际开发中不建议出现
class Cat extends Person {
}

class TestPerson {
    public static void main(String[] args) {
        Man man = new Man();
        // 调用父类方法
        man.setName("张三");
        man.setAge(18);
        man.setGender("男");
        man.show();
        // 调用子类自己独有的方法
        man.setSalary(8000.0);
        man.work();
        System.out.println("*********************************");
        WoMan woMan = new WoMan();
        // 调用父类方法
        woMan.setName("爱丽丝");
        woMan.setAge(18);
        woMan.setGender("女");
        woMan.show();
        // 调用子类自己独有的方法
        woMan.setAppearance(90);
        woMan.shopping();

        // 此时SomeClass没有继承任何类
        // 默认继承了Object
        SomeClass sc = new SomeClass();
        // 可以调用Object中提供的方法
        sc.toString();
        sc.hashCode();
        sc.getClass();
    }
}

class SomeClass {

}
